package com.fuluwa.infra.utils;

import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.cfg.NamingStrategy;

public class MyNamingStrategy extends ImprovedNamingStrategy implements NamingStrategy {

	private static final long serialVersionUID = 1L;

	@Override
	public String columnName(String columnName) {
		return super.columnName(columnName).toLowerCase();
	}

	@Override
	public String tableName(String tableName) {
		return super.tableName(tableName).toLowerCase();
	}

	@Override
	public String classToTableName(String className) {
		return "t_" + super.classToTableName(className).toLowerCase();
	}

	@Override
	public String propertyToColumnName(String propertyName) {
		return "f" + super.propertyToColumnName(propertyName).toLowerCase();
	}
	
	@Override
	public String joinKeyColumnName(String joinedColumn, String joinedTable) {
		return "f" + super.joinKeyColumnName(joinedColumn, joinedTable);
	}
	
	@Override
	public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName,
			String referencedColumnName) {
//		System.out.println("---->"+super.foreignKeyColumnName(propertyName, propertyEntityName, propertyTableName, referencedColumnName));
		return "f"+super.foreignKeyColumnName(propertyName, propertyEntityName, propertyTableName, referencedColumnName);
	}
}
